let app = getApp()
Component({
    properties: {
        mineTitleColor: {
            type: String,
            default: ""
        },
        mineListColor: {
            type: String,
            default: "#fff"
        },
        mineListBorderColor: {
            type: String,
            default: "#eee"
        },
        mineInfoShow: {
            type: Boolean,
            default: !1
        }
      },
      data:{
        styleType:'style1',
        defaultAvatar:'../../../static/image/chat-tx.png',
         mineTitleColor: {
                        type: String,
                        default: ""
                    },
                    mineListColor: {
                        type: String,
                        default: "#fff"
                    },
                    mineListBorderColor: {
                        type: String,
                        default: "#eee"
                    },
                    mineInfoShow: {
                        type: Boolean,
                        default: !1
                    },
        customBaseList:[
            {
                title: "我的订单",
                right: "全部订单",
                rightStyle: "color: #777",
                hidden:false, 
                link: {
                    type: "mine_order",
                    tab: 0
                },
                children:[]    
            }
        ]
        
      },
   
     pageLifetimes: {
        show: function () {
            var that=this
            this.userinfo()
            wx.request({
                url: app.globalData.siteroot,
                data: {
                  do:'Member_getUserCenter',
                  user_id:wx.getStorageSync('user_id')
                },
                success: function(res) {
                  var child=[ {
                    title: "待付款",
                    count:res.data.data.order.pay_count,
                    icon: "/static/icon/icon_mine_order_48_1.png"
                }, {
                    title: "待发货",
                    count:res.data.data.order.deliver_count,
                    icon: "/static/icon/icon_mine_order_48_2.png"
                }, {
                    title: "待收货",
                    count:res.data.data.order.take_count,
                    icon: "/static/icon/icon_mine_order_48_3.png"
                }, {
                    title: "待评价",
                    count:res.data.data.order.comment_count,
                    icon: "/static/icon/icon_mine_order_48_5.png"
                }, {
                    title: "退款/售后",
                    count:0,
                    icon: "/static/icon/icon_mine_order_48_4.png"
                }]
                  that.setData({
                    pageUserInfo:res.data.data.member_data.user_info,
                    children:child,
                    staff_bind_id:res.data.data.member_data.staff_bind_id
                  })
                  wx.setStorageSync('staff_bind_id',res.data.data.member_data.staff_bind_id)
                }
              })
        }
      },
    lifetimes: {
        attached: function () {
            var that=this
            wx.request({
                url: app.globalData.siteroot,
                data: {
                  do:'Member_getUserCenter',
                  user_id:wx.getStorageSync('user_id')
                },
                success: function(res) {
                  var child=[ {
                    title: "待付款",
                    count:res.data.data.order.pay_count,
                    icon: "/static/icon/icon_mine_order_48_1.png"
                }, {
                    title: "待发货",
                    count:res.data.data.order.deliver_count,
                    icon: "/static/icon/icon_mine_order_48_2.png"
                }, {
                    title: "待收货",
                    count:res.data.data.order.take_count,
                    icon: "/static/icon/icon_mine_order_48_3.png"
                }, {
                    title: "待评价",
                    count:res.data.data.order.comment_count,
                    icon: "/static/icon/icon_mine_order_48_5.png"
                }, {
                    title: "退款/售后",
                    count:0,
                    icon: "/static/icon/icon_mine_order_48_4.png"
                }]
                  that.setData({
                    pageUserInfo:res.data.data.member_data.user_info,
                    children:child,
                    staff_bind_id:res.data.data.member_data.staff_bind_id
                  })
                  wx.setStorageSync('staff_bind_id',res.data.data.member_data.staff_bind_id)
                }
              })
            wx.request({
                url: app.globalData.siteroot,
                data: {
                  do:'index_common'
                },
                success: function(res) {
                    var len=res.data.info.tabbar.list.length-1;
                    var show_order=res.data.info.tabbar.list[len].link.member_show_order;
                    if(show_order==1){
                        that.setData({
                            showorder:true
                        })
                    }
                    if(show_order==2){
                        that.setData({
                            showorder:false
                        })
                    }
                    app.globalData.globalColor=res.data.info.common.globle.color
                    that.setData({
                        globalColor:res.data.info.common.globle.color,
                        type_index:res.data.info.tabbar.list[len].link.type_index
                    })
                    if(res.data.info.tabbar.list[len].link.type_index==1){
                        that.setData({
                            styleType:'style1'
                        })
                    }else{
                        that.setData({
                            styleType:'style2'
                        })
                    }
                    var linklist = res.data.info.tabbar.list[len].link.list;
                    if(that.data.styleType=='style1')
                    {
                        var result = [];
                        for(var i=0,len=linklist.length;i<len;i+=3){
                            result.push(linklist.slice(i,i+3));
                         }
                         that.setData({
                            mineList:result
                        })
                    }
                    else
                    {
                        var result=res.data.info.tabbar.list[len].link.list
                        that.setData({
                            mineList:result
                        })
                    } 
                }
              })
         }
      },
    methods: {
        userinfo:function(){
            console.log('用户信息')
        },
        businessinfo:function(){ 
            var that=this
            wx.navigateTo({
                url: '/business-service/pages/staff_newIndex/index'
            })
            wx.request({
              url: app.globalData.siteroot,
               data: {
                 do:'Message_getPushTmplIds',
                 temp_name:'leave_message,place_order,visit_message'
              },
             success: function(res) {
                var leave_message=res.data.info.leave_message
                wx.requestSubscribeMessage({
                    tmplIds: [leave_message],
                    success (res) {
                        wx.request({
                            url: app.globalData.siteroot,
                             data: {
                               do:'Member_subscribeTimes',
                               subscribe_data:[{"leave_message":1},{"place_order":0},{"visit_message":0}],
                               staff_id:wx.getStorageSync('staff_bind_id')
                            },
                           success: function(res) {
                            
                           }
                          })
                    }
                })
             }
            })
            
        },
        information:function(){
            wx.navigateTo({
                url: '/yb_shopv2/native/all/index?type=information',
              })
        },
        allorder:function(){ 
            wx.navigateTo({
              url: '/yb_shopv2/native/all/index?type=mine_order&orderStatusCur=-1',
            })
        }
    }
});
